package com.vpx.server.controller.system;
import com.vpx.server.bean.order.base.BaseDeleteOrder;
import com.vpx.server.bean.order.base.BaseIdOrder;
import com.vpx.server.bean.order.system.*;
import com.vpx.server.bean.result.base.BaseDeleteResult;
import com.vpx.server.bean.result.system.*;
import com.vpx.server.framework.authority.AuthPoicy;
import com.vpx.server.framework.authority.RequestAuth;
import com.vpx.server.framework.base.ResultMsg;
import com.vpx.server.service.system.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author liuks
 * @title: vpx
 * @module: 用户管理
 * @description: 用户管理接口
 * @date 2021/09/11 13:30
 */
@RestController
@RequestMapping(value = "/api/user")
@Api(tags = "基础设置-用户管理")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("insert")
    @ApiOperation("新增用户")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg insert(@RequestBody SysUserOrder order) {
        return sysUserService.insert(order);
    }

    @DeleteMapping("deleteById")
    @ApiOperation("删除用户")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg deleteById(@RequestBody BaseDeleteOrder order) {
        return sysUserService.deleteById(order);
    }

    @PutMapping("updateById")
    @ApiOperation("修改用户")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg updateById(@RequestBody SysUserOrder order) {
        return sysUserService.updateById(order);
    }

    @GetMapping("findById")
    @ApiOperation("查询用户")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<SysUserResult> findById(BaseIdOrder order) {
        return sysUserService.findById(order);
    }

    @GetMapping("pageQuery")
    @ApiOperation("分页查询用户")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<SysUserPageResult> pageQuery(SysUserPageOrder order) {

        return sysUserService.pageQuery(order);
    }

    @GetMapping("findUserRole")
    @ApiOperation("查询用户角色")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<SysUserRoleResult> findUserRole(BaseIdOrder order) {
        return sysUserService.findUserRoleById(order);
    }

    @PostMapping("saveUserRole")
    @ApiOperation("保存用户角色")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg saveUserRole(@RequestBody UserRoleListOrder order) {
        return sysUserService.saveUserRoleList(order);
    }

    @PostMapping("resetUserPwd")
    @ApiOperation("重置用户密码")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg resetUserPwd(@RequestBody BaseIdOrder order) {
        return sysUserService.resetUserPassword(order);
    }

    @PostMapping("updateUserPwd")
    @ApiOperation("修改用户密码")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg updateUserPwd(@RequestBody UserPasswordOrder order) {
        return sysUserService.updateUserPassword(order);
    }



}
